home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1368.dms / var1368.adf / RSRead.Me < prev    next >
Text File  |  1992-09-02  |  41KB  |  687 lines

  1.  
  2.  
  3.              A DEMONSTRATION of the RSA ENCRYPTION ALGORITHM.
  4.              ================================================
  5.       
  6.            ####################################################
  7.            #                                                  #
  8.            #    The author of this demonstration disk is :    #
  9.            #                                                  #
  10.            #             Mr. N. Hensor                        #
  11.            #                86, Teignmouth Road               #
  12.            #                   London  NW2 - 4DX              #
  13.            #                                                  #   
  14.            #    THERE ARE SEVERAL INSECURE FEATURES TO THIS   # 
  15.            #  PACKAGE. ANYONE WISHING TO PURCHASE THE SECURE  #
  16.            #    VERSION, CONTACT ME AT THE ABOVE ADDRESS BY   #
  17.            #           MAIL IN THE FIRST INSTANCE.            #
  18.            #                                                  #         
  19.            #   I also have a wide range of modules for other  #
  20.            #        cryptographic algorithms available.       #
  21.            #    [In C and assembler (Mororola processors)]    #
  22.            #      and will write new modules as required.     #
  23.            #                                                  #
  24.            ####################################################
  25.  
  26.            #--------------------------------------------------#
  27.            
  28.            The program on this disk is only suitable for use
  29.            on Motorola 68000 processors (Amiga 500/600/1000/2000).
  30.            It will not run on 68020 or higher processors. The
  31.            program on this disk was completed in 1992 after which
  32.            a major rewrite was done on an Amiga 1200. This latest
  33.            program makes use of the 68020 long (32bit by 32bit)
  34.            multiply(and divide) to a 64bit product, and the bit
  35.            manipulation instructions available on the 68020. As
  36.            a consequence of this, it is 5.5-7 times faster in
  37.            operation. Furthermore a text-compression first stage
  38.            to encryption has been introduced which alone speeds
  39.            encryption by a factor of 4. Also a new all-assembler
  40.            seiving section is included in the prime-finding 
  41.            section. All in all, the Amiga 1200 system is a much
  42.            more practical proposition than the system on this disk.
  43.            
  44.            #--------------------------------------------------# 
  45.            
  46.       
  47.    The Rivest-Shamir-Adleman encryption algorithm is one of several recently
  48. developed techniques for encryption which put immensely secure encryption
  49. within reach of the home computer user.
  50.  
  51.    This software was written starting with the following objectives:
  52.  
  53.    (a) The highest possible level of text security should be made available
  54.          to the widest possible market.
  55.  
  56.    (b) Encryption speed considerations should not be allowed to intrude on
  57.          questions of encryption quality, but once a scheme had been 
  58.          decided upon, assembler routines would be used to obtain the best
  59.          possible speed.
  60.          
  61.    If you ask the question "What is the ultimate encryption method?", there
  62. is, and never will be, a clear cut answer. However if you draw up a list of
  63. say 10 candidates, then some of them are not suitable for use on
  64. micro-computers. Of the remaining half-dozen which are suitable,
  65. comparisons of security are difficult to arrive at. The RSA algorithm would
  66. be on everyones shortlist and provides immense security.
  67.  
  68.    This algorithm belongs to a class of encryption schemes known as 
  69. "Public-Key" encrption schemes. These schemes provide a simple solution to
  70. the age-old problem of key-distribution. The algorithm is particularly
  71. suited to ensure telecommunications security but can also be used for
  72. personal file security. A detailed discussion of the algorithm can be found
  73. in many reference books, but the next section contains a thumb-nail sketch
  74. of the method. 
  75.  
  76. The Theory of the RSA algorithm
  77. ===============================
  78.    The algorithm makes heavy use of raising integers to an integer power
  79. and then reducing the result using an integer modulus. A brief review of 
  80. these operations will now be given. [All numbers are integers from this
  81. point on unless stated otherwise]
  82. Modular Arithmetic
  83. ------------------
  84.    The result of the operation   a mod b  is the remainder resulting from
  85. dividing a by b.
  86. Hence:
  87.          5 mod 3  = 2
  88.          8 mod 4  = 0   etc.
  89.    Clearly the result is always in the range     0.......(b-1).
  90.  
  91.    More complex operations can be tackled by evaluating "a" first and then
  92. finding   a mod b   as above.
  93. Hence:
  94.          <7cubed> mod 3  =  7*7*7 mod 3  =  343 mod 3 = 1
  95.          
  96.    The RSA algorithm makes use of the following steps for encryption:
  97.    (a) The message is broken into blocks.
  98.    (b) The blocks of text are turned into numbers (integers).
  99.    (c) Each number is raised to a power {e} (the encryption exponent) and
  100.          reduced relative to a modulus {N}.
  101.    (d) (optional) The resulting number is changed into text - solely for
  102.          the purpose of transmission if a modem or hard copy print-out 
  103.          is to be used.         
  104.  
  105.    The resulting text can be restored to its original state by:
  106.    (a) and (b) similar to above.
  107.    (c) Each number is raised to a power {d} (the decryption exponent)
  108.          and reduced relative to the same modulus {N}.
  109.    (d) The resulting number is changed back to text.
  110.    
  111.    The results of these operations depend solely on the 3 numbers {N}, {d}
  112. and {e}. Of these {N} and {e} are published - possibly by use of printed
  113. lists, possibly by use of a mailed floppy disk or any other convenient
  114. means. It is presumed at this point that a potential eavesdropper obtains
  115. copies of these numbers. Hence no security is provided by {N} and {e} and
  116. all security is provided by keeping {d} secret. This number must be kept
  117. locked away and if ever it is suspected that {d} has been compromised, then
  118. a new set of numbers {N}, {e}, {d} found, the new {N}, {e} published and
  119. the new {d} locked away - in short send any potential eavesdropper back to
  120. square 1. There are billions of billions ...........of billions of 
  121. satisfactory numbers and this software package enables them to be found.
  122.    It might be argued that since {N} and {e} are openly published, then it
  123. might be possible for a potential eavesdropper to obtain a {d} by analysis
  124. of {N} and {e}. This is possible if {N} (which is a product of 2 prime
  125. numbers) can be factorized. Factorization is a well known "hard" numerical
  126. problem which we shall briefly discuss.
  127.  
  128.    Factorization algorithms do exist - they are just not very good. The
  129. best available have run times proportional to a constant raised to a power
  130. of SQRT(n. log(n))  where n is the size of the number to be factorized in
  131. either decimal digits or binary bits. To appreciate the significance of 
  132. this formula, let us invent a computer - "the Incredible Mk I" which is 
  133. something like a million times faster than anything yet built. Suppose the
  134. Incredible Mk I can factorize a 30-digit number in 1 nanosecond. (light 
  135. travels 30cm in 1 nanosecond) Run times can be estimated for larger values
  136. as follows:
  137.  
  138.    Decimal Digits in Number      |   Hypothetical Factorization Time
  139.    =================================================================
  140.             30                   |         1   nanosecond
  141.             40                   |        25.1 nanosecond
  142.             50                   |       371   nanosecond
  143.            100                   |       0.031 secs
  144.            150                   |       261   secs
  145.            200                   |       175   hrs
  146.            300                   |     12,947  yrs !!
  147.    ----------------------------------------------------------------
  148.    
  149.    The point of this table is that factorization time climbs so steeply that
  150. any opponent just has to give up at some point. If he can factor 200 digit
  151. composites then use 300 digit composites or 400 digits and so on. All of
  152. this would be academic if it were equally hard to put a suitable composite
  153. together in the first place. In fact your humble Amiga 600 can find 
  154. suitable 300-digit composites in about 8 hrs of running time which the most
  155. powerful computer on the planet would take millions of years to split apart.
  156.    From the point of view of users, the table is revealing in other ways. 
  157. It should be clear that security can be set at any desired level with this
  158. algorithm, in proportion to the risks attendant upon disclosure. If large
  159. sums of money or even life and limb are at risk, then choose an {N} with
  160. upwards of 300 digits and change these parameters regularly. On the other
  161. hand a personal diary might be satisfactory with a 50 digit {N} and not 
  162. bother changing at all.
  163.    The drawback with choosing very large {N} values is the speed of
  164. encryption. Very roughly the speed of encryption (chars/sec)falls off as 
  165. the square of the number of digits in {N}. With an {N} of about 100 digits,
  166. this software encrypts/decrypts at about 2 chars/sec and hence encrypting
  167. a message of 1000 characters with an {N} of 300 digits will take about 1 hr.
  168.    Clearly the size of {N} has to be carefully considered before selection.
  169. In the software you will be asked to set a value for the size of {N} in
  170. binary bits. It takes about 3.32 binary bits to represent each decimal digit
  171. and hence if an {N} of 300 digits is desired, this corresponds to about
  172. 1000 binary bits.
  173.  
  174. Getting Started with the Software
  175. =================================
  176.    The software package is a collection of modules and movement from module
  177. to module is controlled by the special function keys. F10 is always an exit
  178. key and the lower number keys are used for selections.
  179.    At the top level, F1-F3 will be the most used keys. Pressing F3 permits
  180. access to various housekeeping utilities. As a first step press F3 to enter
  181. this Miscellaneous section. A list of the  utilities will then appear. Let 
  182. us now check that the printer is correctly set up.
  183.    This demonstration software package assumes:
  184.    (a) The printer is connected to the parallel port.
  185.    (b) The printer DIP switches are set to receive English symbols (ISO 4)
  186.          and will insert a carriage-return when it receives a new-line(0x0A)
  187.          command. The Amiga uses a new-line command on its own as a line
  188.          terminator.
  189.    (c) This software package requires the printer to act in a similar way
  190.          to an old fashioned teletype in that visual access is required to
  191.          each line as it is printed. Lasers and inkjets do not permit this
  192.          and paper consumption with these will be prodigious. The ideal
  193.          printer is a dot-matrix type printing to fanfold paper.
  194.  
  195.    Press now F7 which will transfer any disk-file to the printer after you
  196. have entered the file path-name. If the outcome is not satisfactory, then 
  197. the DIP switches on the printer will have to be adjusted and F7 tried again
  198. until success has been obtained.
  199.    As a second test of the printer, let us use the silent-screen facility.
  200. In this software package, the message which has to remain secure is always
  201. kept off the VDU. VDU's are insecure in that it is possible to capture the
  202. electromagnetic emissions and reconstitute the display using a nearby 
  203. receiver. Even a printer is moderately insecure since cases of shredded 
  204. paper being reconstituted have been revealed. However if the printer output
  205. is incinerated and the ash pulverised, then a printer will be secure. By
  206. default, the silent-screen message entry facility (F5) will not echo input
  207. to the printer; it will pass it straight to a disk file 
  208. "df0:RSpublic/silent.txt". However it is possible to change this by 
  209. altering a global variable in section F1, so press F1 now to enter this 
  210. section. The 3 global variables "nRabin", "FileStnData", and "SStoprin" can
  211. now be changed. Press now the following keys in order:
  212.     
  213.     7, <enter>, 1, <enter>, 1, <enter> and then F1 signalling OK.
  214.     
  215.    The significance of these variables will be explained shortly, but for 
  216. the moment setting "SStoprin" to 1 will force section F5 to echo your input
  217. line-by-line to the printer. (These variables remain in their set-state
  218. until section F1 is re-entered or until the Amiga is reset). Now we are
  219. ready to enter the silent screen section so press F5. You will be given the
  220. option of exiting the section but press F1 to proceed. (These early-exit
  221. options are included to provide a way out for anyone making a wrong 
  222. key-press)
  223.    Enter now any line of text. Note that the cursor moves but that no text 
  224. appears on the VDU. When you press <enter>, the line is output to the 
  225. printer and can be inspected together with a chance to accept/reject it. In
  226. this way a message can be built up line by line until a zero-length line is
  227. input signifying the end of text entry. Before you do this make sure that
  228. 1 of your lines contains a "£" sign and check that your printer
  229. correctly reproduces it. If it does not, then your printer DIP switches
  230. will need adjusting until it is set to receive English symbols. When you
  231. have completed line entry, you might re-enter section F7 to examine the
  232. complete text that you have just entered.
  233.    Most of the remaining Miscellaneous utilities will be described below, 
  234. but section F6 can be described now. The final stage of any secure 
  235. communication process requires the destruction of any residual evidence. On
  236. the Amiga, the AmigaDOS command "DELETE" is available to delete files.
  237. Unfortunately, this command leaves the file unchanged - it merely destroys
  238. the linkage system which AmigaDOS requires to find a file and marks the
  239. sectors on which the file is physically stored as "available for storeage".
  240. It is fairly easy to recover a file in this state from a disk and hence the
  241. DELETE command is not secure. Utility F6 performs the following steps:
  242.    (a) The number of characters in the file is determined.
  243.    (b) The file is overwritten with "U" symbols.
  244.    (c) The file is set to zero length.
  245. In this way all information is obliterated. If you inspect your directory
  246. (after F6 has been used) with the AmigaDOS "LIST" command, you will find 
  247. that the obliterated file still exists but is marked "empty". This is a 
  248. sure indicator that F6 has been used. You might want to use "DELETE" at this
  249. point to remove the stub. 
  250.    Press now F10 to exit the Miscellaneous section and return to the top 
  251. level. Let us now consider the problem of finding prime numbers - the 
  252. feedstock of modern cryptology. Section F5 permits direct access to the 
  253. prime number seeking software. This section is a stand alone module not
  254. related to the main purpose of the package. it was included for the purpose
  255. of anyone tinkering with prime numbers. However the modules are the same 
  256. ones used by F4 and it is easier to get familiar with the prime number
  257. seeking software using F5 rather than F4. So press F5 now. Press F1 to get
  258. past the early-exit check and then start to enter your "job-file". Enter
  259. the following numbers:
  260.  
  261.       250  <enter>  240  <enter>  1  <enter>  1  <enter>
  262.       250  <enter>  240  <enter>  2  <enter>  1  <enter>
  263.       250  <enter>  240  <enter>  3  <enter>  1  <enter>      
  264.  
  265.    Then press F1 to approve your input. This job-file will find one prime
  266. number of each type supported, each of moderate size. (250-240 bits) There
  267. is no point in seeking large primes on this familiarisation tour, since all
  268. that happens is the software takes longer and longer. No further input is
  269. needed so sit back and watch the software work.
  270.    The software first of all selects a value for the most significant set
  271. bit between the limits you have specified. This is done using a random 
  272. number generator. The second stage is to build up a random number of the 
  273. required length, again using the random number generator. This then acts as
  274. a starting point for the search. Blocks of numbers ( 1block = 768 
  275. consecutive numbers throughout this package) are now searched for primes.
  276. Searching is a two stage process. the first stage eliminates all numbers
  277. divisible by all the small primes from 2 to 65521 inclusive. When this stage
  278. is complete, there are usuallly about 40 numbers remaining which might still
  279. be prime. The remaining candidates are then tested using Rabin's algorithm.
  280. Rabin's algorithm takes as input 2 numbers:
  281.    (a) The candidate number to be tested for primality.
  282.    (b) A random integer called a "witness" used in the test.
  283. It has two possible outcomes:
  284.  
  285. NOT PRIME:  If this is returned, then the candidate is DEFINITELY not prime.
  286.  
  287. PRIME:      If this is returned, there is a 75% chance that the number is 
  288.             prime, and a 25% chance that it is not.
  289.             
  290.    Hence, there is a chance that a candidate is not actually a prime but the
  291. test indicates that it is. In this event, the "witness" is known as a "false
  292. witness". Now this, by itself won't do. However, if we apply the test again
  293. with a new "witness", the chances of finding 2 false witnesses in succession
  294. are 0.25 * 0.25  or 1 chance in 16, and we can carry on finding new 
  295. witnesses, testing again and driving down the probability of error by a 
  296. further factor of 4. After 10 trials the chances of an error are 
  297. approximately 1 in 1 million. The number of Rabin tests to be applied is 
  298. held in a variable called nRabin. if you have been following this 
  299. introduction in detail, you will recall that we set nRabin to a value of 7
  300. in the Miscellaneous section F1.(This value is too low for serious work, but
  301. is good enough for demonstration purposes.) By default this value is set at
  302. 30 which will give very high quality results - many authorities recommend
  303. a value of 20. This test is implemented in assembler for maximum speed.
  304.    Returning now to the progress report on screen, each candidate is being
  305. examined in this way until a successful outcome is obtained. When a prime 
  306. has been found, it is written to file "df0:RSpublic/prime.data", and the 
  307. next item on the job-file started. This output file can be printed out using
  308. Miscellaneous F2 when all tasks are completed.
  309.    If you have entered the job-file as above, then the prime.data file will
  310. contain:
  311.    (a) 1 simple prime.
  312.    (b) 1 RSA-suitable prime.
  313.    (c) 1 safe prime.
  314.    What do these terms mean? A simple prime is just a prime number. The 
  315. first few are 2,3,5,7,11 etc. An RSA-suitable prime is a prime suitable for
  316. use with the RSA algorithm. Recall that {N} is the product of 2 primes 
  317. conventionally refered to as {p} and {q} ie N = p * q. When the RSA
  318. algorithm was first published, a method of attacking it was discovered which
  319. although feeble, can be countered by finding a {p} and {q} such that:
  320.                   p  = 2.k'.p'  + 1
  321.                   p' = 2.k''.p''+ 1  ( ditto for q )
  322.    Where k' and k'' are small primes and p, p', p'' are large primes. These
  323. recommendations are built into this package. The technique is to find a 
  324. simple prime to serve as p'', then try succesive low primes k'' until a 
  325. prime p' is found. If you watch the progress report, you will see k'' 
  326. increase apparently erratically. This occurs because p' is tested with a
  327. seive as a first stage, but this takes place so quickly that no attempt is
  328. made to display the results. When the seive is unable to eliminate the p',
  329. the k'' is displayed and Rabin's test is used on p'. Once a p' has been 
  330. found, the cycle is repeated to find a p which will be the RSA-suitable
  331. prime we require. One property of this technique is that the size of p 
  332. cannot be precisely controlled since the size of the "k's" is not known in
  333. advance. Later on when you use this module to set up an {N} value for 
  334. encryption purposes you will find that the {N} value that is output will be
  335. a few bits different from your input demand, and this is a result of the 
  336. technique described above.
  337.    A safe-prime was a name used in a text-book discussing problems in
  338. cryptology. I personally don't believe there to be anything "safe" about
  339. them - look upon it as just a label. A safe-prime as defined here is a 
  340. prime such that:
  341.             p = 2.p' + 1       where p' is a simple-prime
  342.    Such primes have (p-1)/2 principal roots, and since there are a lot of 
  343. them, it is a simple matter to find one. Such values are needed to set up
  344. the 3 128-bit pseudo-random number generators which provide a source of
  345. random bits for various low-grade tasks in the software. Safe-primes have 
  346. a nasty property in that there are very large runs containing none of them.
  347. If your starting point leaves you in such a run, you may prefer to reset 
  348. your Amiga rather than wait for it to exit.
  349.    The "cycle-time" refered to at the base of the screen is a rough
  350. estimate of the time to make one Rabin test. It is not better than about 10%
  351. or 2 secs whichever is greater. The cycle-time for 250-bit numbers is 8.5sec
  352. and for 750-bit numbers 170secs. Another big influence on total run time, is
  353. the distribution of primes themselves. For 250-bit numbers about 1 number in
  354. 173 is a prime and for 750-bit numbers about 1 in 520. Allowing for both
  355. these influences, the total run-time varies in proportion to the cube of
  356. the number of bits set (but with a very wide scatter on individual runs)
  357.    This software package can handle numbers of 2024 bits (approx 616 
  358. decimal digits) but you will be limited to 2000 bits in section F5.
  359. However, run times for such enormous numbers will be many days or even 
  360. weeks.
  361.  
  362.    If you have been working steadily through this introduction, you should
  363. by now be developing a feel for the trade off between speed and security
  364. provided by the RSA algorithm. So by now you will be ready to set up your
  365. own {N}, {e}, {d} numbers. In this text these 3 numbers are called a 
  366. station and setting them up called station set-up. In regular computer
  367. parlance, the word station refers to the hardware of a terminal, but in this
  368. report, the word station refers to an individual users numbers. In an office
  369. with say 1 terminal and 20 users, we would say that there were 20 stations.
  370.    In setting up a station, we go through the following steps:
  371.    (a) Find {p}, {q} - 2 RSA-suitable primes.
  372.    (b) Find {N} = p * q.
  373.    (c) Find a value called {Phi}.
  374.    (d) Find values {d}, {e} which depend upon {Phi}
  375.    The values {N}, {d}, {e} have to be saved and the values {p}, {q}. {Phi}
  376. can be discarded. Since we assume that a potential eavesdropper can find out
  377. {N} and {e} without too much trouble, we must be aware that:
  378.    
  379.    If {N}, {e} are known by an eavesdropper, then knowledge of ANY ONE OF 
  380. THE VALUES {p}, {q}, or {Phi} DESTROYS THE SECURITY OF THE RSA SCHEME.
  381.    
  382.   Consequently, we must take great care with the disposal of these 3 values.
  383. By default, in this package, these 3 values are not stored on disk,
  384. displayed on the VDU or output to the printer. ie they are only ever 
  385. stored in memory and these values can be destroyed by powering the machine
  386. down after station set-up is complete. However, for educational purposes,
  387. it is possible to over-ride this state of affairs by setting flag
  388. "FileStnData" to 1 in Miscellaneous F1. If you have been following this 
  389. introduction in detail, you will already have done this - if not set this
  390. flag to 1 now. When this flag is set, all 6 station numbers are written to
  391. file "df0:RSpublic/prime.data" in the order {p}, {q}, {N}, {Phi}, {d}, {e},
  392. and can be copied to the printer using Miscellaneous F2, when the station 
  393. set-up is complete.
  394.    One final point should be made before we enter the station set-up 
  395. section. Setting up a new station destroys the old station parameters on
  396. your disk. Consequently, you must be working with a fresh copy of your disk
  397. so that you retain a copy of your old parameters. This is necessary for the
  398. following reasons:
  399.    (i) If you are changing your station numbers regularly as a security
  400. measure, there will always be someone who sends you messages using your 
  401. obsolete station values, and you will be unable to decrypt these messages
  402. if your old station values are lost. Incidentally this problem highlights
  403. the need for rigid procedures in distributing station numbers.
  404.    (ii) If you are archiving your incoming messages for reference purposes,
  405. these messages must be stored in encrypted form and your old station
  406. numbers will always be needed to read these old messages.
  407.  
  408.    So now armed with a freshly copied disk, we can now set up a new station
  409. so press F4. Before the main work starts the 3 128-bit pseudo-random number
  410. generators used for various low-grade tasks are reset. Each of these is set
  411. up by:
  412.    (a) Finding a safe-prime of suitable size as a modulus. (actually the 
  413.          size is in the range 112-128 bits) This is done automatically using
  414.          the old generators.
  415.    (b) Finding a multiplier which can be manually input or set 
  416.          automatically (just press <enter> when prompted). If you input the
  417.          multiplier yourself, it will be left or right shifted until it is
  418.          of a satisfactory size - in other words your input controls the 
  419.          most significant bits (they may not be immediately recognisable
  420.          since since they may have been bit-shifted). This multiplier 
  421.          should be a principal root, so it is tested and if it is not a 
  422.          principal root then (multiplier+1), (multiplier+2) etc are tried
  423.          until a principal root is found.
  424.    When all 3 generators have been reset, (normally a few minutes only) the
  425. main station numbers are started upon. You will be prompted to input the 
  426. number of bits in {N}. This is the key variable which we have discussed
  427. above which dictates security level and speed. For the purpose of this
  428. introductory tour, a value of 350 bits will suffice so enter this now. if 
  429. you are coming to this point for real, you must make your own decision,
  430. based on the discussion above.
  431.    Three prime-searching displays will now appear, 2 RSA primes and 1 
  432. simple prime, in that order.(these are {p}, {q} and {d} being found) After
  433. this you will be asked to input a password. It should be clear from the 
  434. discussion above that all security in the RSA scheme relies on {d} being
  435. kept secret, and once it has been revealed all security vanishes. In an
  436. office environment, it is very easy to leave a disk lying about in a 
  437. moments carelessness, with the possibility of security being compromised.
  438. If your security problems are severe, then you would have to adopt this
  439. assumption and reset your station. However if your problems are less severe
  440. (ie unlikely to be attracting the interest of national agencies) it would
  441. be beneficial if the {d} value were hidden from an unsophisticated
  442. opponent. The scheme that has been used is:
  443.    (a) The {d} value is exclusive-ORed with a random value and scatter 
  444.          loaded into a large (8k) array of random numbers.
  445.    (b) The precise details of this operation are controlled by a password
  446.          together with the 128-bit pseudo-random number generator in drawer
  447.          "df0:RSprivate".
  448.    (c) The password is turned into a number in this process and the 
  449.          following points about this should be noted.
  450.       (i) Upper-case and lower-case letters produce the same bit-patterns
  451.             in the number - hence a password of "FRED" will be just as 
  452.             effective in retrieving {d} as "fred".
  453.       (ii) The symbols "g", "G", "w", "W", "0" all produce no set bits in
  454.             the number. Hence passwords like "www" produce a number of zero
  455.             which would produce a crash.(such passwords are trapped and
  456.             refused)
  457.       (iii) All symbols on the light-tan keys are active and contribute to
  458.             the number, which means that passwords like "A  U" produces a
  459.             different number from "A U" (different number of spaces) 
  460.             ie all punctuation symbols have an effect.
  461.    It must be emphasised that this system is only a defence against a 
  462. "nosey parker" and not to be relied on against a sophisticated opponent.
  463.    After your password has been input, the station set-up will take a 
  464. further few minutes to complete. Your new station parameters will be in
  465. "df0:RSpublic/Ne1.data" (holds {N}, {e}) and "df0:RSprivate/d1.data"
  466. (hides {d}). Since we have FileStnData set, all six values have been copied
  467. to "df0:RSpublic/prime.data" file and so you can go into Miscellaneous F2
  468. and have them printed out.
  469.  
  470.    At this point the {{N}, {e}} pair need to be circulated to all network
  471. members. In the full system, this is accomplished by copying {N} and {e}
  472. to a seperate disk "RSStation:" using Miscellaneous F4 and posting this to
  473. all members who can add in their own pair, copy it and then pass it on. On
  474. this demonstration system, there is no seperate disk, and using 
  475. Miscellaneous F4 adds the {N} {e} pair into a file 
  476. "df0:RSstation/Station.data". In order to circulate this, you will have to 
  477. use AmigaDOS to copy this file to a spare disk and circulate it in this way.
  478. This demonstration system permits only 2 stations in this file. For users
  479. who are just experimenting with the system, it is not necessary to 
  480. circulate your numbers in this way and you can just write messages to
  481. yourself. (ie skip Miscellaneous F4)
  482.  
  483.    Now we are ready to start encrypting messages. The "silent screen" 
  484. utility is intended for use when entering secure messages, but any word 
  485. processor package will do for demonstration purposes, so prepare a short
  486. message now. the following points should be observed in message 
  487. preparation:
  488.    (a) The message alphabet is restricted to the light-tan keys on your
  489.          Amiga keyboard with the exception of the "#" symbol. This symbol
  490.          is transmuted into a "?" symbol. The "£" symbol (0xA3 internally)
  491.          is changed to "#" (0x23 internally) on input which is the ISO 4
  492.          representation. (For the technical, all symbols 0x20 - 0x7D 
  493.          inclusive are valid with the single exception above)
  494.    (b) The only control characters accepted are <newline> (0x0A) and
  495.          carriage-return (0x0D). All other symbols are turned into "?"
  496.          symbols at encryption time. In particular the "ESCAPE" character
  497.          (0x1B) used by many word-processors and printers to change printer
  498.          mode (to "itallic", "bold-on" etc. etc.) is NOT VALID! Hence your
  499.          message must exclude ALL PRINT ENHANCEMENT FEATURES.
  500.    (c) The two symbols <.s> must not occur together in the file name. as 
  501.          will be explained below the decryption module searches for the
  502.          occurences of <.s> to determine wether an encrypted file has been
  503.          signed or not. Hence file-names like <my.script> will cause the
  504.          decryption module to fail. (the solution is simple - just rename
  505.          your file)
  506.          
  507.    Encryption is a straightforward operation - just press F1 and respond as
  508. prompted. If this is your first entry into this section, do not select
  509. "signing" when requested. If your input file was eg "df1:my.text" then the
  510. encrypted file will be "df1:my.text.e". Four appendages are used in this
  511. software and these are:
  512.    <s> - this message has been signed.
  513.    <e> - this message has been encrypted.
  514.    <d> - this message has been decrypted.
  515.    <u> - this message has been un-signed.
  516. thus:
  517.    my.text.se   has been signed and encrypted.   
  518.    my.text.e    has been encrypted.
  519.    my.text.ed   has been encrypted and then decrypted.
  520.    my.text.sedu has been signed, followed by encryption; then decrypted
  521.                   and finally unsigned.
  522.    Your encrypted file my.text.e can now be printed out using Miscellaneous
  523. section F7. Note that it is a straightforward text-file consisting of
  524. symbols 0-9, A-F, + spaces + newlines and hence is suitable for modem 
  525. transmission. You will also notice that the file is roughly 3-times longer
  526. than your original file. This is principally because a homophonic 
  527. substitution is used as a first stage in encryption. Details will not be
  528. discussed here. Suffice it to say that this improves security with small or
  529. medium sized {N} values.
  530.    Decryption is also straightforward. Just press F2 and respond to the 
  531. prompts. You might like to experiment with erroneous passwords to convince
  532. yourself that it is impossible to retrieve {d} successfully without a
  533. correct password. Your decrypted file will be in file "df1:my.text.ed" which
  534. can be printed out and will be identical to your original file. If it is 
  535. not then your original text contained non-valid characters whose presense
  536. will be revealed by "?" symbols appearing in strange places.
  537.  
  538.    The procedure above can now be repeated but for a signed-encryption 
  539. rather than a plain encryption. The <.se> file that results is about 9 
  540. times longer than the original because a double homophonic substitution
  541. has been used. On decryption, the software will test for the <.s> appendage
  542. and conclude that the text needs unsigning to retrieve the plaintext.
  543.    A final point about encryption/decryption needs appreciating. As the 
  544. software proceeds from stage to stage, it obliterates the input file and 
  545. writes the output file to disk. During encryption, this means that your
  546. starting plaintext file will be lost, leaving you with a <.e> or a <.se> 
  547. file for your archive - which is correct from the security viewpoint, since
  548. these are the only files that can be safely stored. During decryption, the
  549. <.e> or <.se> file is again obliterated in forming the <.ed> or <.sedu> 
  550. file - which is a plaintext file. This causes 2 problems:
  551.    (a) If the recipient requires to archive the message, then he must copy
  552.          the <.e> or <.se> file to his archive before decryption - 
  553.          otherwise it will be lost.
  554.    (b) The <.ed> or <.sedu> (plaintext) files cannot safely be left on disk.
  555.          After inspection (copying to the printer with Miscellaneous F7 -
  556.          NOT the VDU) the file must be destroyed by Miscellaneous F6. Note
  557.          that Miscellaneous F6 actually overwrites the disk-tracks with
  558.          garbage unlike the AmigaDOS DELETE command which just destroys
  559.          the links between file and access-system. It is just not possible
  560.          to do this file obliteration automatically.
  561.  
  562.    Thats all Folk's! The only section that we have not visited is
  563. Miscellaneous F3, which is not much use until such time as "Station.data"
  564. is part-filled by using F4. Both of these sections are self-evident.
  565.  
  566.    The principal assembler routine at the heart of this software has been 
  567. timed at 7 times faster on the Amiga 1200 than on an Amiga 600.(the extra
  568. length of the multiply and divide instructions play a big part in this).
  569. The Amiga 4000 should provide a 4-5 speed gain above an Amiga 1200 and this
  570. would then be a secure terminal able to keep up with most typists.
  571.  
  572.       ADDITIONAL NOTES FOR USERS WITH SEVERE SECURITY PROBLEMS
  573.       ========================================================
  574.       
  575.    The conventional model of an eavesdropper, is of someone working a 
  576. wiretap and rushing off at intervals to hand his offerings to a bespectacled
  577. mathematician sitting at a super-computer terminal who breaks the cipher in
  578. a few moments. Such a scheme has little hope of success against the RSA
  579. algorithm. You might think that the security authorities would give up at
  580. this point. Wrong! They are not in the giving-up business. If one technique
  581. fails, then they will dust off another.
  582.    Few things are easier to bug than a personal computer. The only way to be
  583. sure of the contents of a black plastic chip is to slice it open and examine
  584. it with a microscope. Who could say that it doesn't contain a short-range
  585. radio transmitter broadcasting your keystrokes? The following procedures
  586. will be needed to ensure security.
  587.  
  588.    (a) When purchasing your Amiga take Sherlock Holmes' advice and don't go
  589. to the first dealer that springs to mind, nor the second but the third and
  590. then insist on selecting one yourself. Seal all access panels and screws
  591. with epoxy resin. The same procedure is required with your printer and 
  592. cable, since these 3 items are the obvious points of attack. 
  593.  
  594.    (b) Your {d} value hidden in file "d1.data" must be made secure and the
  595. password made as long and as obscure as possible.
  596.  
  597.    (c) Your station parameters should be changed as often as possible. This
  598. limits damage after attack (b) but is not effective against attack (a).
  599.  
  600.    
  601.  
  602.                            NOMENCLATURE
  603.                            ============
  604. composite : A non-prime. Hence a composite can be expressed as the product
  605.             of at least 2 primes.
  606.             
  607. encrypt : The process of transforming a message to an unintelligible form.
  608.           (see decrypt). In the RSA scheme, the recipients public-key is
  609.           needed to accomplish this. Thus if a message has to be 
  610.           transmitted to say 7 different people, then 7 seperate 
  611.           encryptions will be needed. Also since the public-keys are not
  612.           secret in the RSA scheme, a third-party can use the public-keys to
  613.           forge a message.("signing" stops this possibility)
  614.           
  615. decrypt : The process of transforming an unintelligible message back to an
  616.           intelligible state.(see encrypt) In the RSA scheme, the recipients 
  617.           private-key is needed to accomplish this. The private-key must be
  618.           kept secret - all secrecy in the RSA scheme relies on this. In 
  619.           this implementation the private-key can only be accessed by entry
  620.           of a password.
  621.           
  622. homophonic substitution : A very old technique used originally to destroy
  623.           letter frequency information by using multiple alternative
  624.           substitutes for common letters. In this implementation, it is used
  625.           to increase the "fan-out" as follows. The letter "e" has 13 
  626.           alternative 8-bit representations chosen at random. This means
  627.           that a message "eee" has 13 * 13 * 13 possible representations 
  628.           when encrypted. This increases the number of possible
  629.           ciphertexts well beyond the number of possible messages. This
  630.           technique also makes it possible to have spaces and other 
  631.           punctuation marks in the text (space has 21 representations) 
  632.           when normal cryptographic practice is to delete them.
  633.           
  634. key : The information needed to encrypt/decrypt a message. Conventionally
  635.       one key does both functions but in the RSA scheme a "public-key" is
  636.       used for encryption and a "private-key" for decryption. Public-keys
  637.       can be openly distributed to anyone who asks for them without loss of
  638.       security.
  639.  
  640. originator : The person who wishes to transmit a message to a recipient.
  641.  
  642. private-key : The information needed to decrypt a message. In the RSA 
  643.               scheme the private-key is a single very-large number refered
  644.               to as {d} (for decryption exponent).
  645.  
  646. public-key  : The information needed to encrypt a message. This is 
  647.               invariably the recipients public-key which may be published
  648.               in a document like a telephone directory, but in this
  649.               implementation will be found from a disk-file "Station.data".
  650.               If you are yourself the recipient (adding to a personal
  651.               secure archive) then the public-key will be available in
  652.               disk-file "df0:RSpublic/Ne1.data". In the RSA scheme the 
  653.               public-key consists of 2 very large numbers {N} and {e}.
  654.  
  655. recipient : The only person who can decrypt an incoming encrypted message.
  656.             Equivalently, the person to whom the message is directed.
  657.             
  658. signing : The process by which an originator identifies a message uniquely
  659.           with himself. In the RSA scheme, signing is a similar process to
  660.           encryption but using {d} (the private key) as the encryption
  661.           exponent rather than {e}. A signed message is not secure by 
  662.           itself and must be followed immediately by a standard encryption
  663.           to make it secure. The resulting signed and encrypted message
  664.           can only be decrypted by the intended recipient, who can then be 
  665.           completely certain of the originators identity. A signed message
  666.           cannot be forged by a third party intent on mischief. Futhermore
  667.           a recipient receiving instructions involving high-risk to himself
  668.           might want to insist on the instructions being signed as proof of
  669.           the originators identity. Signing is a very strong concept
  670.           cryptographically. There is every hope that it will be accepted
  671.           in law shortly as contractually binding. The concept of "signing"
  672.           opens up a whole new field of use for cryptology beyond the
  673.           obvious secret communication one. Using signed messages, "deals"
  674.           or "contracts" can be struck instantly between any two parties
  675.           anywhere on the planet without the need for signed and witnessed
  676.           documents. An all-electronic contract would consist of a signed
  677.           message of proposal and a reply of a signed message of acceptance.
  678.           Such all-electronic dealing cannot be forged by a third party and
  679.           neither signatory could deny that a deal had been struck at some
  680.           future date.
  681.           
  682. principal-root : A number (a) such that the set of numbers
  683.                  {<a> mod p, <a*a> mod p, ......<a^(p-1)> mod p } [p prime]
  684.                  is the set
  685.                   {1, 2, 3, ........(p-1)} permutated (ie shuffled up).
  686.           
  687.